package com.bluedon.ism.commons.entity;


import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 组织表
 */
@Entity
@Table(name = "ORGANIZATION")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Organization implements java.io.Serializable {

	private String oid;
	private String name;
	private String fullName;
	private Boolean disabled;
	private String parentId;
	private District district;
	private String did;
//	private Set<Contact> contacts = new HashSet<Contact>(0);
	private Set<Account> accounts = new HashSet<Account>(0);


    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "OID", unique = true, nullable = false, length = 100)
    public String getOid() {
        return oid;
    }

    public void setOid(String oid) {
        this.oid = oid;
    }
    
    
    
	@Column(name = "NAME", nullable = false)
	public String getName() {
		return this.name;
	}
    public void setName(String name) {
		this.name = name;
	}
    
    @Column(name = "FULL_NAME", nullable = false)
	public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    @Column(name = "DISABLED", precision = 1, scale = 0)
	public Boolean getDisabled() {
		return this.disabled;
	}

	public void setDisabled(Boolean disabled) {
		this.disabled = disabled;
	}

	@Column(name = "PARENT_ID", precision = 10, scale = 0)
    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="DID")
    public District getDistrict() {
        return district;
    }
    public void setDistrict(District district) {
        this.district = district;
    } 	

//	@OneToMany(fetch = FetchType.LAZY, mappedBy = "organization")
//	public Set<Contact> getContacts() {
//		return this.contacts;
//	}
//    public void setContacts(Set<Contact> contacts) {
//		this.contacts = contacts;
//	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "organization")
	public Set<Account> getAccounts() {
		return this.accounts;
	}

	public void setAccounts(Set<Account> accounts) {
		this.accounts = accounts;
	}

	@Column(name = "did")
	public String getDid() {
		return did;
	}

	public void setDid(String did) {
		this.did = did;
	}

}
